<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use App\Admin\Line;

class LineController extends Controller
{
  public function index()
  {
  	$data = Line::all();
  	return view('admin.line.index', compact('data'));
  }

  public function add()
  {
  	return view('admin.line.add');
  }

  public function store(Request $request)
  {
  	$this -> validate($request, [
			'line_name'  => 'required',
			'line_area'  => 'required', 
			'line_price' => 'required',
			'line_time'  => 'required',
			'line_type'  => 'required',
			'start_time' => 'required',
			'contact'    => 'required',
			'phone'      => 'required',
  	]);

		$line = Line::create([
			'line_name'  => $request -> line_name,
			'line_area'  => $request -> line_area, 
			'line_price' => $request -> line_price,
			'line_time'  => $request -> line_time,
			'line_type'  => $request -> line_type,
			'start_time' => $request -> start_time,
			'contact'    => $request -> contact,
			'phone'      => $request -> phone,
		]);  	


		return redirect() -> route('line.index', [$line]);
  }
}
